﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using GroundWater.BusinessActions;
using GroundWater.Data;

namespace GroundWater
{
    /// <summary>
    /// ReadWaterLevelService 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
    // [System.Web.Script.Services.ScriptService]
    public class ReadWaterLevelService : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod]
        public List<GroundWater.Data.WaterlevelData> ReadWaterlevel(string startDate, string endDate)
        {
            DataTable dt = Monitoring.FetchWaterLeveDataByDate(startDate, endDate);

            List<GroundWater.Data.WaterlevelData> list = new List<GroundWater.Data.WaterlevelData>();

            foreach (DataRow row in dt.Rows)
            {
                GroundWater.Data.WaterlevelData data = new GroundWater.Data.WaterlevelData();
                data.WellCode = row["WellCode"].ToString();
                data.MonitorTime = row["MonitorTime"].ToString();
                data.Waterlevel = row["Waterlevel"].ToString();

                list.Add(data);

            }

            return list;
        }

        [WebMethod]
        public int UpdateConcurrencyByDate(string startDate, string endDate)
        {
            int cnt = Monitoring.UpdateConcurrencyByDate(startDate, endDate);
            return cnt;
        }

    }

    
}
